Barazo default frontend
barazo.forum
1/**
2 * Category error boundary -- catches errors loading category views.
3 * Common triggers: category not found, access denied, network failure.
4 * Next.js requires a default export for error boundaries.
5 */
6
7'use client'
8
9import { useEffect } from 'react'
10import Link from 'next/link'
11import { usePathname } from 'next/navigation'
12import { WarningCircle, ArrowClockwise, House } from '@phosphor-icons/react'
13import { reportError } from '@/lib/error-reporting'
14
15export default function CategoryError({
16 error,
17 reset,
18}: {
19 error: Error & { digest?: string }
20 reset: () => void
21}) {
22 const pathname = usePathname()
23
24 useEffect(() => {
25 document.title = 'Error | Barazo'
26 reportError(error, { boundary: 'category', path: pathname })
27 }, [error, pathname])
28
29 const message =
30 process.env.NODE_ENV === 'development'
31 ? error.message
32 : 'This category could not be loaded. It may not exist or you may not have access.'
33
34 return (
35 <>
36 <title>Error | Barazo</title>
37 <div className="flex min-h-[40vh] items-center justify-center bg-background px-4">
38 <div role="alert" aria-live="assertive" className="w-full max-w-md text-center">
39 <WarningCircle size={48} className="mx-auto mb-4 text-destructive" aria-hidden="true" />
40 <h1 className="mb-2 text-xl font-bold text-foreground">Could not load category</h1>
41 <p className="mb-6 text-sm text-muted-foreground">{message}</p>
42 <div className="flex items-center justify-center gap-3">
43 <button
44 type="button"
45 onClick={reset}
46 className="inline-flex items-center gap-1.5 rounded-md border border-border px-4 py-2 text-sm font-medium text-foreground transition-colors hover:bg-muted"
47 >
48 <ArrowClockwise size={16} aria-hidden="true" />
49 Try again
50 </button>
51 <Link
52 href="/"
53 className="inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary-hover"
54 >
55 <House size={16} aria-hidden="true" />
56 Return to forum
57 </Link>
58 </div>
59 </div>
60 </div>
61 </>
62 )
63}